package com.rowger.player.base

//选择继承v4，可以适配4.0上
import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import org.jetbrains.anko.AnkoLogger
import org.jetbrains.anko.runOnUiThread
import org.jetbrains.anko.toast

/**
 * Created by luojie on 2018/4/14.
 * 所有Fragment的基类
 */
abstract class BaseFragment:Fragment(),AnkoLogger {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        init()
    }

    protected fun init() {
       
    }

    override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        return initView()
    }
    /*
    *获取布局View
    * */
    abstract fun initView(): View?


    override  fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        initLisener()
        initData()
    }
    //数据的初始化
    protected open fun initData() {

    }
    // adapter  listener
    protected open fun initLisener() {

    }

    fun myToast(msg:String){
        context.runOnUiThread { toast(msg) }
    }
}